package com.ham.mud.commands;

import com.ham.mud.ServerConnection;
import com.ham.mud.characters.player.Player;
import com.ham.mud.rooms.Room;
import com.ham.mud.rooms.RoomService;

/**
 * Created by hlucas on Jun 28, 2011 at 2:43:04 PM
 */
public class RecallCommand extends PlayerCommand {
    @Override
    public void execute(ServerConnection connection, String[] params) {
        connection.printSolo("You pray for transportation.");
        Player player = connection.getPlayer();
        int atX = player.getAtX();
        int atY = player.getAtY();
        Room room = RoomService.getRoom(player.getZone(), atX, atY);
        room.removePlayer(connection, null);

        player.setZone("town");
        player.setAtX(0);
        player.setAtY(0);

        Room newRoom = RoomService.getRoom("town", 0, 0);
        newRoom.addPlayer(connection, null);
        
        new LookCommand().execute(connection);
    }

    @Override
    protected String getCommandName() {
        return "recall";
    }
}
